package filters.pull;

import helper.PlanarImageWrapper;

import javax.media.jai.JAI;

import org.apache.log4j.Logger;

import at.fhv.framework.filter.PassivePullFilter;

/**
 * The SourceFilter class.
 * 
 * @author Michael Sieber
 */
public class SourcePullFilter extends PassivePullFilter<String, PlanarImageWrapper> {
	private static Logger LOGGER = Logger.getLogger(SourcePullFilter.class);
	private String _source;

	/**
	 * 
	 * @param source
	 */
	public SourcePullFilter(String source) {
		super(null);
		_source = source;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public PlanarImageWrapper read() {
		return createEntity();
	}

	/*
	 * {@inheritDoc}
	 */
	@Override
	protected boolean execute(PlanarImageWrapper entity, String data) {
		return true;
	}

	/*
	 * {@inheritDoc}
	 */
	@Override
	protected PlanarImageWrapper createEntity() {
		LOGGER.debug("Loading image: " + _source);
		return new PlanarImageWrapper(JAI.create("fileload", _source));
	}
}
